# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pywayland
pkgname=python-pywayland
pkgver=0.4.17
pkgrel=1
pkgdesc="Python bindings for the libwayland library"
arch=(loong64 x86_64)
url="https://github.com/flacjacket/pywayland"
license=(Apache-2.0)
depends=(
  glibc
  python
  python-cffi
  wayland
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
  wayland-protocols
)
checkdepends=(python-pytest)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('9ca1e30b56f6d1447744451d15d84041d5ce6ce64811ca0e395822731f0c7cd1d8571f640b89771d8f5e9da1d82385734974e10e68ccecffc0f9600a83d2478b')
b2sums=('f190107ab361ec9c0a568d22a104fa06a7e52a348a6226c30c2ae542b77e5b21b4a389ad745efb864b58cff9e77cb22ff43fd6614859cb138d398a84b99614a5')

build() {
  cd $_name-$pkgver
  python pywayland/ffi_build.py
  python -m pywayland.scanner
  python -m build --wheel --no-isolation
}

check() {
  local _py_ver="$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')"

  cd $_name-$pkgver
  mkdir -vp temp
  export PYTHONPATH="build/lib.linux-$CARCH-$_py_ver:$PYTHONPATH"
  export XDG_RUNTIME_DIR="$PWD/temp"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname"
}
